'''
[题目链接](https://kamacoder.com/problempage.php?pid=1070)
'''

def main():
    index = 0
    vec = []
    presum = 0
    result = {}
    data = input().split()
    lens = len(data)
    n = int(data[index])
    p = [0] * n
    for i in range(n):
        vec.append(int(data[i+1]))
        presum += vec[i]
        p[i] = presum
    index = index + 1 + n

    while index < lens:
        a , b = int(data[index]), int(data[index+1])
        index += 2
        key = ''.join([str(a),'-',str(b)])
        if a == 0 :
            result[key] = p[b]
        else :
            result[key] = p[b] - p[a-1]
    for rs in result.items():
        print(rs)

if __name__ =='__main__':
    main()




